package cn.tedu.spring.eg3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Component
public class ShopController {
    //演示Spring Bean生命周期
    /*
        1.实例化[构造方法]
        2.属性赋值[set方法]
        3.初始化[@PostConstruct]
        4.使用
        5.销毁[@]
     */
    private String bean;
    public ShopController(){
        System.out.println("构造 Hello");
    }
    public ShopController(String bean) {
        this.bean = bean;
    }
    @Value("1")
    public void setBean(String bean) {
        this.bean = bean;
        System.out.println("set Hello");
    }
    @PostConstruct
    public void init(){
        System.out.println("init Hello");
    }
    @PreDestroy
    private void die(){
        System.out.println("die Hello");
    }
}
